A complete annotated reference for Go — from basic syntax through concurrency primitives, interfaces, embedding, and production snippets. Example code adapted from A Tour of Go. Click any operator or code copy button to copy to clipboard.
implements keyword needed.File hello.go — run with $ go run hello.go
| Operator | Description |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Quotient |
| % | Remainder |
| & | Bitwise AND |
| | | Bitwise OR |
| ^ | Bitwise XOR |
| &^ | Bit clear (AND NOT) |
| << | Left shift |
| >> | Right shift |
| Operator | Description |
|---|---|
| == | Equal |
| != | Not equal |
| < | Less than |
| <= | Less than or equal |
| > | Greater than |
| >= | Greater than or equal |
| Operator | Description |
|---|---|
| && | Logical AND |
| || | Logical OR |
| ! | Logical NOT |
| Operator | Description |
|---|---|
| & | Address of / create pointer |
| * | Dereference pointer |
| <- | Send / receive operator (see Channels) |
builtin packagefor, no whilefor — no while, no until. The three forms cover all loop patterns. Labels allow break and continue to target an outer loop explicitly.implements keywordimplements declaration is needed. This decouples interface definitions from implementations.Functions that can fail return an additional error value. nil error means success.
embed packagehttp.Handler